// axios.js
import axios from 'axios';

// 创建 axios 实例
const instance = axios.create({
  timeout: 10000, // 请求超时时间
});

// 请求拦截器
instance.interceptors.request.use(
  config => {
    // 设置默认的 Content-Type 为 application/json
    config.headers['Content-Type'] = 'application/json';
    const token = localStorage.getItem('authToken');
    const tokenHead = localStorage.getItem('Bearer');
    config.headers['Authorization'] = tokenHead + token;
    return config;
  },
  error => {
    // 处理请求错误
    return Promise.reject(error);
  }
);


export default instance;